\section{Category Theory}
Consider the two functors $Id:RING\rightarrow RING$ and $M_n(-):RING\rightarrow RING$. The collection of maps 
$\iota_R: R\rightarrow M_n(R), r\mapsto diag(r,\ldots,r)$ defines a natural transformation $Id_{RING}\Rightarrow M_n(-)$. 


\textcolor[rgb]{1,0,0}{Don't get this: $r\mapsto (r)$,
$R\mapsto M_1(R)$ is a natural isomorphism}
\textcolor[rgb]{0,0,1}{Basically, it is a natural transformation as it preserves ring homomorphisms and that it is an isomorphism as we can create another natural isomorphism $\eta: M_1(R) \ra R$ given by $(r) \mapsto r$.}

Question: When are two categories the same?
\begin{Definition}[isomorphic and equivalent categories]
Two categories $\CC$ and $\DD$ are
\begin{itemize}
	\item isomorphic if there exist functors
	$F: \CC\rightarrow \DD$ and $G: \DD\rightarrow \CC$ with 
	$G\circ F = Id_{\CC}$ and $F\circ G=Id_{\DD}$
	\item equivalent if there exists functors 
	$F: \CC\rightarrow \DD$ and $G: \DD\rightarrow \CC$ with $G\circ F$ naturally isomorphic to $Id_{\CC}$ and $F\circ G$ naturally isomorphic to $Id_{\DD}$.
	Call $F,G$ mutually inverse equivalences: $\CC\simeq \DD$. 
\end{itemize}
\end{Definition}

\begin{Theorem}
Let $R$ and $S$ be rings. Then $MOD_R\times MOD_S \cong MOD_{R\times S}$
\end{Theorem}
\begin{proof}
An object $(M,N)\in MOD_R\times MOD_S$ can be regarded as an $(R\times S$)-module via $(m,n)\cd(r,s)=(m\cd r, n \cd s)$, and a morphism in $MOD_R\times MOD_S$ can be regarded as a morphism in $MOD_{R\times S}$.

In the other direction, any $(R\times S$) module $L$ is isomorphic to an $(R\times S)$ module of the form
$M\oplus N$ where $M=L \cd (1_R,0_S)$ and $N=L\cd(0_R,1_S)$. Thus the equivalence is given by 
$MOD_R\times MOD_S \rightarrow MOD_{R\times S}$, $(M,N)\mapsto M\oplus N$, $(\alpha,\beta)\mapsto \alpha\oplus \beta$.
\end{proof}

\subsection{Adjoint functors}

To talk about adjoint functors we first have to define natural transformations of bifunctors. (The following is a Theorem from CWM.

\begin{Lemma}
For two bifunctors $H,J: \BB\times \CC \rightarrow \DD$ the function $\alpha(b,c):S(b,c)\rightarrow S'(b,c)$ is a natural transformation $\alpha: S\Rightarrow S'$ iff $\alpha(b,c)$ is natural in $b$ for each $c$ in $\CC$ and $\alpha(b,c)$ is natural in $c$ for each $b$ in $\BB$.
\end{Lemma}
\begin{Definition}[Adjoint functors]
(D Kan, 1958)
Consider (covariant) functors $F: \CC\rightarrow \DD$ and $G:\DD\rightarrow \CC$.
Form two bifunctors $$H: Mor_{\CC}(-,G(-)): \CC^{op}\times \DD \rightarrow SET, (C,D)\mapsto Mor_{\CC}(C,G(D)) \text{ and} $$
$$J: Mor_{\DD}(F(-),-): \CC^{op}\times \DD \rightarrow SET, (C,D)\mapsto Mor_{\CC}(F(C),D)~~~~$$ 

\textcolor[rgb]{1,0,0}{Does this make sense? $F$ is a functor from $\CC$, how can I consider $F(C)$ when $C$  is an object in $C^{op}$. Indeed $C^{op}$ is used to make the bifunctors covariant. Have to think about why that's the case. }

The notation indicates that both are contravariant in the first variable and covariant in the second variable.
So $F$ is left adjoint to $G$ and $G$ is right adjoint to $F$ ( so $(F,G)$ is an adjoint pair) if there exists a natural isomorphism 
$$\eta: H \stackrel{\cong}{\rightarrow} J,$$
 i.e. there exists a family of bijections
$$\eta_{C,D}: Mor_{\DD}(F(C),D)\rightarrow Mor_{\CC}(C,G(D))$$
 that are natural in $\CC$ and $\DD$.
\end{Definition}

\begin{Example}[Free modules, $Fr_R$ and the forgetful functor $\Upsilon$ are adjoint]
Let $R$ be a ring, $Fr_R: SET \rightarrow Mod_R$ be the free module functor and $\Upsilon: Mod_R\rightarrow SET$ be the forgetful functor. Then $FR_R$ is left adjoint to $\Upsilon$. \textcolor[rgb]{1,0,0}{($\Upsilon$ should also be right adjoint!)}
$$Mor_{SET}(X,\Upsilon(M))\cong Mor_{MOD_R}(Fr_R(X),M) $$
for any set $X$ and any module $M$. This is proven in the next Theorem.

\begin{Theorem}
Let $R$ be a ring, $X$ be a set and $M$ be a $R$-module. The universal property of free modules induces a bijection between the set functions (=set morphisms) from $X$ to $\Upsilon(M)$ and the module homomorphisms from $Fr_R(X)$ to $M$.
$$Mor_{MOD_R}(Fr_R(X),M)\stackrel{}{\longleftrightarrow}Mor_{SET}(X,\Upsilon(M)).$$ 
As $Fr_R$ and $\Upsilon$ are adjoint functors, we claim that this property behaves naturally as $X$ and $M$ vary.

Likewise, $Fr: SET \rightarrow GP$ is left adjoint to the forgetful function \mbox{$\Upsilon: GP\rightarrow SET$}.

$$\xymatrix{X \ar[dr]_{\text{set function}} \ar[r]^{\mu~~} & Fr_R(X) \\
&  M\ar@{<-}[u]_{ \exists ! \text{ module hom.}}}$$
\end{Theorem}
\end{Example}
\subsection{Initial and Terminal Objects}
There is a 'metatheorem' that every univsersal object in a category can be regarded as an initial object in some related category.
\begin{Definition}[initial object]
An initial object of a cateogry $\CC$ is an object $I$ in $\CC$ such that for all $C$ in $\CC$ there exists a unique morphism
$\iota_{C}:  I\rightarrow C$,
i.e. $Mor_{\CC}(I,C)=\{\iota_C\}$.
\end{Definition}
Dually we define a terminal object.
\begin{Definition}[terminal object]
A terminal object of a category $\CC$ is an object $T$ in $\CC$ such that for all $C$ in $\CC$ there exists a unique morphism $\tau_C: C\rightarrow T$, i.e. $Mor_{\CC}(C,T)=\{\tau_C\}$.

There is a one to one correspondence of initial object in $\CC$ and terminal objects in $\CC^{op}$.
\end{Definition}

\begin{table*}
	\centering
		\begin{tabular}{llll}
      Category & Initial Object & Terminal Object \\
			SET & $\emptyset$ & any singleton \\
			GP & 1 & 1\\
			$Mod_R$	& 0 & 0 \\
			RING &  $\ZZ$ & 0 (1=0)\\
			RNG & 0 & 0\\
			FIELD & - & -\\
			TOP & - & any singleton\\
			$TOP_0$ & any singleton & any singleton\\
			poset $\NN^{div}$ & 1 (1 divides every other number) & -
			
		\end{tabular}
		\label{InitialObject}
		\caption{initial and terminal objects}
\end{table*}

The following Lemma states the uniqueness (up to unique (!) isomorphism) of initial (and dually terminal) objects.
\begin{Lemma}
If $I$ and $I'$ are intinial objects in $\CC$, then $Mor_{\CC}(I,I')=\{\iota_{I}\}$ and $Mor_{\CC}(I',I)=\{\iota_{I'}\}$ where $\iota_{I}: I\rightarrow I'$ and $\iota_{I'}: I'\rightarrow I$ are inverse isomorphisms.
\end{Lemma}
\begin{proof}
$$\xymatrix{I \ar@{.>}[r]^{ \iota_{I}} \ar[dr]_{ id_I } & I' \ar@{.>}[d]^{ \iota_{I'}} \\
&  I}$$
\end{proof}

\begin{Example}[don't worry]
In algebraic geometry, a presheaf on a topological space $X$ is a contravariant functor from the poset of open subsets of $X$ to $AB$ that sends the initial object $\emptyset$ to the terminal object 0 of AB.
\end{Example}

\begin{Definition}[product]
Let $\CC$ be a category with objects $C',C''$. In general, if it exists the product of $C'$ and $C''$is the object $C' \Pi C''$ in $\CC$ together with morphisms $\pi': C' \Pi C''\rightarrow C'$ and $\pi'': C' \Pi C'' \rightarrow C''$ with the universal property that whenever we have morphisms $\beta': B\rightarrow C'$ and $\beta'': B\rightarrow C''$ in $\CC$ where $B$ is an arbitrary object in $\CC$ then 
$$\xymatrix{ & & C'\\
B \ar@{.>}[r]^{\exists ! \gamma} \ar@/^/[urr]^{ \beta'} \ar@/_/[drr]_{\beta''} & C'\Pi C'' \ar[dr]^{\pi''} \ar[ur]_{\pi'} \\
& & C''\\
&  I}$$
\end{Definition}

\begin{Example} We give some examples for products.
\begin{itemize}
	\item $SET: $ The definition coincides with the usual definition. The same can be easily done for $GP$ and $MOD_R$. For two $R$-modules their product is $M'\oplus M''$.
	\item $TOP: $ The product is not obvious but also not difficult to decide what topology to put on the product to make the above definition work.
	\item In $FIELD$ there doesn't exists a product (note: the set theoretic product of two fields is not a field).

\end{itemize}
We will see that a product of two objects is a terminal object in a related category. Define a product category $PRD(C',C'')$: objects are triples $(B,\beta',\beta'')$ with $B$ arbitray in $\CC$ and the morphisms from $\CC$, $\beta':B\rightarrow C'$ and $\beta'': B\rightarrow C''$.

Then a product $C'\Pi C''$ is a terminal object $T$ in the product category $PRD(C',C'')$.
$$\xymatrix{
 & & C'\\
B \ar@{.>}[r]^{\exists ! \gamma} \ar@/^/[urr]^{ \beta'} \ar@/_/[drr]_{\beta''} & T \ar[dr]^{\pi''} \ar[ur]_{\pi'} \\
& & C''
&  I}$$
\end{Example}

Dually the coproduct is an initial object in the coproduct category $COPRD(C',C'')$. $COPRD(C',C'')$ is obtained the same way as $PRD(C',C'')$ but arrows/morphisms are reversed.

$$\xymatrix{& &  C'\\
I \ar[urr] \ar[drr] \ar@{.>}[r] & A \ar[ur] \ar[dr] \\
& &  C''
}.$$



\begin{Example}[coproducts]

\begin{itemize} We give examples for coproducts.
	\item $SET$: The coproduct is the disjoint union $C'\sqcup C''$.
	\item $MOD_R$: The coproduct of two $R$-modules $M'$ and $M''$ is the direct sum $M'\oplus M''$. Note that the coproduct is the same as the product! In this case we also call the product/coproduct the biproduct or direct sum. This relates to $Mor_{MOD_R}(M,N)=Hom(M_R,N_R)$ is an abelian group.
	\textcolor[rgb]{1,0,0}{How does this relate?}
	\item GP: The coproduct of two groups $G'$ and $G''$ is their free product $G'*G''$, with elements formal products $h_1h_2\cdots h_k$ $(k\geq 0)$ with each $h_i$ in either $G'$ or $G''$, both $1_{G'}$ and $1_{G''}$ being identified with the empty string $\emptyset$. Multiplication is given by concatenation of strings.
	If $G_i=<X_i | R_i>$ for $i=1,2$ then $G_1\ast G_2=<X_1 \sqcup X_2 | R_1 \sqcup R_2>$. 
\end{itemize}

\end{Example}

\subsection{Pullback, Pushout}

\begin{Definition}[Pullback, fibre product, cartesian square]
Let $\CC$ be a category with object $Z$. The slice category $ID_Z$ consists of all tuples $(C,f)$ where \mbox{$f: C\rightarrow Z$} is a morphism. We identify the tuple $(C,f)$ with the morphism $f$. \textcolor[rgb]{1,0,0}{(Is this a correct definition of the slice category?)}. Let $f:X\rightarrow Z$ and $g: Y\rightarrow Z$ be two morphisms (=objects) in $ID_Z$. A pullback of $f$ and $g$ is a terminal object $P$ with two morphisms $p_1: P\rightarrow Y$ and $p_2:P\rightarrow X$ in $ID_Z$ such that the following diagram commutes. \textcolor[rgb]{1,0,0}{(I pretty much adapted this definition from wikipedia. Our definition did not depend on $f$ and $g$. How can the pullback be in the slice category anyways? It should be )} 
$$
\xymatrix{
P \ar[r]^{p_1} \ar[d]_{p_2} & Y\ar[d]^{g} \\
X \ar[r]_{f}& Z
}
$$
Furthermore the pullback has the universal property that for any other object $Q$ with morphisms $q_1:Q\rightarrow Y$ and $q_2:Q\rightarrow X$ there is exactly one morphism from $Q$ to $P$ such that the following diagramm commutes.

$$\xymatrix{
Q \ar@{.>}[dr]\ar[drr]^{q_1} \ar[ddr]_{q_2} \\
& P \ar[dr] \ar[r] \ar[d] & Y \ar[d]\\
& X \ar[r] & Z } $$
The pullback is also called fibre product or cartesian square. One often denotes the pullback $A=X\times_Z Y$.

\end{Definition}
\begin{Example} We give some examples for pullbacks.

\begin{itemize}
	\item $SET$: The Pullback of $f: X\rightarrow Z$ and $g:Y\rightarrow Z$ is 
	$$X\times_Z Y =\{(x,y)\in X\times Y | f(x)=g(y)\}.$$
	\item $MOD_R$: The pullback of $\alpha_i: M_i\rightarrow N$ $i=1,2$ is 
	$$M_1 \times_N M_2=\{(m_1,m_2)\in M_1\times M_2 | \alpha_1(m_1)=\alpha_2(m_2)\}.$$
\end{itemize}
\textcolor[rgb]{1,0,0}{How does this coincide with the definition of the pullback where the pullback was a set of morphisms? Do we  just identify the object $(C,f)$ with the object $C$ now?}
\end{Example}

\subsection{Pushout}
Dual to the pullbacks are the pushouts.

We start with the cocartesian square

$$\xymatrix{
W \ar[r] \ar [d] & X \ar[d] \ar@/^/[ddr]\\
Y \ar@/_/[drr] \ar[r] & Z \ar@{.>}[dr]^{\exists !}\\
& & Z'}$$ 

\begin{Example} We give an example for groups.

\begin{itemize}
	\item GP: The pushout is the free product with amalgamation
	
	$$\xymatrix{
	H \ar[r]^{\alpha_1} \ar[d]_{\alpha_2} & G_1 \ar[d]\\
	G_2 \ar[r] & G_1*_H G_2
		}	$$
		If $G_i=<X_i | R_i>$ for $i=1,2$ then 
		$$G_1*_H G_2=<X_1 \sqcup X_2 | R_1,R_2, \alpha_1(h)=\alpha_2(h) \forall h\in H>.$$
\end{itemize} 

\end{Example}

\begin{Theorem}[van Kampen]
Fundamental group functor  $\pi_1: TOP_0 \rightarrow GP$ sends the bicartesian square ($X_1,X_2$ are subsets of some big space)

$$\xymatrix{
X_1\cap X_2 \ar@^{^{ (}->}[r] \ar@^{^{ (}->}[d] & X_2 \ar@^{^{ (}->}[d] \\
X_1\ar@^{^{ (}->}[r] & X_1\cup X_2
}
$$ to the cocarteisan square 

$$\xymatrix{
\pi_1(X_1\cap X_2) \ar@^{^{ (}->}[r] \ar@^{^{ (}->}[d] & \pi_1(X_2) \ar@^{^{ (}->}[d] \\
\pi_1(X_1) \ar@^{^{ (}->}[r] & \pi_1(X_1\cup X_2)\cong \pi_1(X_1)*_{\pi_1(X_1\cap X_2)} \pi_1(X_2)
}
$$
\end{Theorem}

\subsection{Extended products and coproducts} 
So far we have been looking at products and coproducts of two objects. In the following we extend the terms of product and coproduct to sets of objects with arbitrary cardinality.

The universal property gives a unique isomorphism such that 
$$(X\times Y) \times Z \cong X \times (Y \times Z).$$

We already discussed the case $MOD_R$ where the product and the coproduct coincide
$$prod(M_1,M_2) = coprod(M_1,M_2) =M_1\oplus M_2.$$

The coproduct, i.e direct sum, demands that almost all entries of an infinite tuple are $0$ whereas the product, i.e. direct product, allows arbitrary entries.
\begin{itemize}
	
	 \item product=$\Pi_{i\in I} M_i=\{(m_1,m_2,\ldots ) | m_i\in M_i\}$ when $I\subset \NN$.
	
	\item coproduct=$\bigoplus _{i\in I} M_i = \{(m_1,m_2,\ldots) | m_i\in M_i,\text{ almost all } m_i=0\}$
\end{itemize}


\subsection{Universal object=Initial Object?}
Informally, there exist two features of a universal object in a category $\CC$. 

\begin{itemize}
	\item Typically, it sits in a commuting diagram in $\CC$ where there exists a unique morphism that completes the diagram.
	\item It corresponds to an initial object in some category related to $\CC$.
\end{itemize}
Since initial objects are unique up to unique isomorphism, the same is true for universal objects. We can refer to 'the' universal object with a certain property (if it exists).

\begin{Example}
Some examples...
\begin{itemize}
	\item  The pullback of the two morphisms $\alpha: X\rightarrow Z$ and $\beta: Y\rightarrow Z$ in $\CC$ is the intial object $(PRD(\alpha:X\rightarrow Z, \beta: Y\rightarrow Z))^{op}$ where $\alpha$ and $\beta$ are objects of $(ID_{\CC})_Z$.
\item Ring $R$, $Fr_R: SET \rightarrow MOD_R$ free module functor.
$\Upsilon : MOD_R \rightarrow SET$ forgetful functor.
$Fr_R(X)$ has properties 

\begin{enumerate}
	\item $\forall$ $R$ modules $N_R$ 
	$$\xymatrix{ X \ar[rr]^{\text{set function}}  \ar[drr]_{\text{set function}} & &Fr_R(X) \ar@{.>}[d]^{\exists ! \text{$R$-hom}}\\
	& & N }$$
	\item $Mor_{MOD_R}(Fr_R(X), N) \leftrightarrow Mor_{SET}(X,\Upsilon(N))$	
	
	Interesting is the related category in which $Fr_R(X)$ is an initial object. The related category $\CC'$ is the category of $R$-modules $\Upsilon$-under-$X$ denoted by $\Upsilon ^X$.
\begin{itemize}
\item Objects: $(M,\xi)$ with $M$ an $R$-module and $\xi: X\rightarrow \Upsilon M$ is a set function. 
\item Morphisms:  $\alpha: (M,\xi)\rightarrow (N,\zeta)$ is given by commutating triangle

$$
\xymatrix{
M \ar[rr] \ar[dd]_{\alpha}& & \Upsilon M \ar[dd]^{\Upsilon_{\alpha}}\\
& X \ar[ur]^{\xi} \ar[dr]_{\zeta}\\
N \ar[rr] & &  \Upsilon N
}$$
The related initial object in $\Upsilon^X$ is $(Fr_R(X),\xi_0)$.
$$MOD_R\stackrel{\Upsilon}{\rightarrow} SET  $$
$$
\xymatrix{
Fr_R(X) \ar[rr] \ar[dd]_{\alpha}& & \Upsilon Fr_R(X) \ar@{.>}[dd]^{\Upsilon_{\exists ! \alpha}}\\
& X \ar[ur]^{\xi} \ar[dr]_{\zeta}\\
N \ar[rr] & &  \Upsilon N
}$$
\end{itemize}


\end{enumerate}

\end{itemize}
\end{Example}

\begin{Definition}[$G$-under-$C$ category]
Let $G: \DD \rightarrow \CC$ be a functor and $C$ an object of $\CC$. The category of objects $G$-under-$C$ has as objects all pairs $(f,D)$ with $D$ in $\DD$ and $f:C\rightarrow G(D)$. It has arrows $h:(f,D)\rightarrow (f',D')$ all those $h:D\rightarrow D'$ in $\DD$ such that $f'=G( h) \circ f$.
\end{Definition}


\begin{Theorem}[D. Kan, 1958]
Let $G:\DD \rightarrow \CC$ be a functor. The following are equivalent

\begin{itemize}
	\item For all objects $C$ of $\CC$ there exists an object $F(C)$ of $\DD$ and a morphism \mbox{$u_c: C\rightarrow G(F((C))$} in $\CC$ (and object in the $G$-under-$C$ category) such that $(F(C),u_c)$ is an initial object in the $G$-under-$C$ category $G^C$.
	\item $G$ has a left adjoint $F:\CC\rightarrow \DD$.
\end{itemize}


\end{Theorem}
Given this theorem, we can now formally define a universal construction to be a functor that has a right adjoint functor.
\begin{Example}
See MacLane and Herrlich \& Strecker.
\end{Example}
\textcolor[rgb]{1,0,0}{What is missing here?}